package DataObjects;

import java.util.*;

import Main.Consts;
import Main.Pair;

public class Article {
	private int id;
	private String text;;
	private Vector<Topic> topics;
	private String title;

	private Collection<Pair<String,Object>> metadata;
	
	//TODO need topics
	public Article(int id,String title,String text,Collection<Pair<String,Object>> metadata){
		this.id=id;
		topics=new Vector<Topic>();
		this.text=text;
		this.metadata=metadata;
		this.title=title;
	}
	
	public String getTitle() {
		return title;
	}

	public void addTopic(Topic topic){
		topics.add(topic);
	}

	public String getText() {		
		return text;
	}

	public int getId() {
		return id;
	}

	public Collection<Topic> getTopics(){//TODO do samthing
		Vector<Topic> ans=new Vector<Topic>();
		for(Topic topic : topics){
			ans.add(topic);
		}
		return ans;
	}

	public String getSummary(){
		int index=text.indexOf("==");
		String ans;
		if (index==-1)
			ans=text;
		else
			ans=text.substring(0,index);
		if (ans.length()>=Consts.SUMMARY_LEN){
			ans=ans.substring(0,Consts.SUMMARY_LEN)+"...";
		}
		return ans;
	}
	
	public Collection<Pair<String, Object>> getMetadata() {
		return metadata;
	}
}